﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="SitePages.aspx.cs" Inherits="SitePages" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        function confirm_delete() {
            if (confirm("Are you sure you want to delete") == true)
                return true;
            else
                return false;
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<div class="box-border formContainer">

      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  
            AllowSorting="True" AllowPaging="True" DataSourceID="SQlUserType"  
            AutoGenerateDeleteButton="True"  DataKeyNames="PageId"  OnRowCreated="GridView1_RowCreated" >
            
          <Columns>
            
              
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="PageId" HeaderText="PageId" InsertVisible="False" 
                  ReadOnly="True" SortExpression="PageId" />
              <asp:BoundField DataField="PageName" HeaderText="PageName" 
                  SortExpression="PageName" />
              <asp:BoundField DataField="PageURL" HeaderText="PageURL" 
                  SortExpression="PageURL" />
              <asp:CheckBoxField DataField="DefaultPage" HeaderText="Default Page" 
              SortExpression="DefaultPage" />
          </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SQlUserType" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT [PageURL], [PageName], [PageId],DefaultPage FROM [tblSitePages] where IsDeleted=0 " 
            InsertCommand="INSERT INTO [tblSitePages]([PageName],PageURL,isDeleted,DefaultPage)VALUES (@PageName,@PageURL,0,@DefaultPage)" 
            UpdateCommand="UPDATE tblSitePages SET PageName = @PageName ,PageURL = @PageURL ,DefaultPage=@DefaultPage WHERE PageId = @PageId" 
            DeleteCommand="UPDATE tblSitePages SET IsDeleted=1 WHERE PageId = @PageId">
            
            <DeleteParameters>
                <asp:Parameter Name="IsDeleted" />
                <asp:Parameter Name="PageId" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="PageName" />
                <asp:Parameter Name="PageURL" />
                <asp:Parameter Name="PageId" />
                <asp:Parameter Name="DefaultPage" />
                
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="PageName" />
                <asp:Parameter Name="PageURL" />
                <asp:Parameter Name="DefaultPage"   />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" 
            AutoGenerateRows="False" DefaultMode="Insert"  DataSourceID="SQlUserType">
            <Fields>
                <asp:BoundField DataField="PageURL" HeaderText="PageURL" 
                    SortExpression="PageURL" />
                <asp:BoundField DataField="PageName" HeaderText="PageName" 
                    SortExpression="PageName" />
                <asp:BoundField DataField="PageId" HeaderText="PageId" InsertVisible="False" 
                    ReadOnly="True" SortExpression="PageId" />
                <asp:CheckBoxField DataField="DefaultPage" HeaderText="Default Page"  />
                
                 
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>

        </div>
</asp:Content>
